class Settings < ActiveRecord::Base

  def self.get_gallery_name
    name=Settings.find_by_title('gallery_name')
    if name==nil
      name=Settings.create(:title => 'gallery_name',:value=>'Untitled gallery')
    end
    name
  end

  def self.set_gallery_name(title) 
    name=Settings.find_by_title('gallery_name')
    if name==nil
      name=Settings.create(:title => 'gallery_name',:value=>'Untitled gallery')
    end
    name.value="#{title}"
    name.save  
  end
  
  def self.get_need_login
    need=Settings.find_by_title('need_login')
    if need==nil
      need=Settings.create(:title => 'need_login',:value=>'1')
    end
    (need.value=='0' ? false: true)
  end
  
  def self.set_need_login(flag)
    need=Settings.find_by_title('need_login')
    if need==nil
      need=Settings.create(:title => 'need_login',:value=>'1')
    end
    need.value=(flag== '1' ? '1':'0') 
    need.save   
  end
  
   def self.get_scheme
    name=Settings.find_by_title('scheme')
    if name==nil
      name=Settings.create(:title => 'scheme',:value=>'default')
    end
    name.value
  end

  def self.set_scheme(title) 
    name=Settings.find_by_title('scheme')
    if name==nil
      name=Settings.create(:title => 'scheme',:value=>'default')
    end
    name.value="#{title}"
    name.save  
  end 
  
  def self.set_cloud_range(range)
    name=Settings.find_by_title('cloud_range')
    if name==nil
      name=Settings.create(:title => 'cloud_range',:value=>'12')
    end
    name.value="#{range}"
    name.save 
  end
  
   def self.get_cloud_range
    name=Settings.find_by_title('cloud_range')
    if name==nil
      name=Settings.create(:title => 'cloud_range',:value=>'12')
    end
    name.value
  end

end
